package cn.rubintry.bug.hunting.common.extension

import android.view.View
import android.view.ViewGroup.MarginLayoutParams


var View?.visible: Boolean
    get() {
        return this?.visibility == View.VISIBLE
    }
    set(value) {
        if(value){
            this?.visibility = View.VISIBLE
        }else{
            this?.visibility = View.GONE
        }
    }

fun View?.marginTop(pxValue: Int){
    val layoutParams = this?.layoutParams
    if(layoutParams is MarginLayoutParams){
        layoutParams.topMargin = pxValue
    }
    this?.layoutParams = layoutParams
}

fun View?.paddingTop(pxValue: Int){
    this?.let {
        this.setPadding(this.paddingLeft , pxValue , this.paddingRight , this.paddingBottom)
    }
}